package easy.netty.net.ws;

import easy.netty.net.core.AbsServer;
import easy.netty.net.core.ws.WsServerIoHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author cengy
 */
public abstract class WsServer
        extends AbsServer {

    public WsServer() {
        super();
    }

    @Override
    protected ChannelHandler newHandler() {
        return new WsServerIoHandler(this);
    }

    @Override
    protected void initChannel0(Channel ch) throws Exception {

        ChannelPipeline p = ch.pipeline();
        p.addLast(new HttpServerCodec())
                .addLast(new HttpObjectAggregator(65535));
        super.initChannel0(ch);
    }
}
